      IMPLICIT REAL*8 (A-H, L-Z)
      real*8 porb(10000),mdot(10000),dt(10000)
      real*8 p(100),md(100),a(100),b(100)
      real*8 porb1,md1,dt1,dt2,dt3(100,100)
      integer i,j,k
      open(4,file='lps.dat',status='unknown')
      open(1001,file='lps0.dat',status='unknown')      
      p(0) = 0.0317
      md(0) = -12
 
      
      do i = 1, 45
      p(i) = 10**(log10(p(i-1))+ 0.1)

      
      do j = 1, 64
      md(j) = md(j-1) + 0.125

      rewind(4)
      dt2 = 0      
      do k = 1,108849
      read(4,*)porb1,md1,dt1      
c      porb1 = 10**porb1
      if(porb1.le.p(i).and.porb1.gt.p(i-1).and.
     &  md1.gt.md(j-1).and.md1.le.md(j))then
      
      dt2 = dt2+dt1
      dt3(i,j) = dt2
      endif


      enddo

      write(1001,11)log10(p(i)),md(j),dt3(i,j)     
11    format(2f8.3,1E12.2,1f8.3)

      enddo
      enddo      
      end

            
